<template>
	<view class="content">
		<navbar :title='title'>
		</navbar>
		<view class="content">
			<u-sticky offset-top="0">
				<view class="xuanview">
					<view class="souviewtwo">
						<text class="dinname">订单日期</text>
						<view class="riitem" @click="gettime(1)">
							{{start?start:'请选择'}}
						</view>
						<text class="hxian">-</text>
						<view class="riitem"  @click="gettime(2)">
							{{end?end:'请选择'}}
						</view>
					</view>
					<view class="tuanone">
						<u-tabs style="width: 100%;" :list="tablist" active-color="#1A1A1A" inactive-color="#666666" :is-scroll="true" :current="current" @change="change"></u-tabs>
					</view>
					<view class="zong">
						<text class="zongnum">共{{total}}笔订单</text>
						<text class="zongnum ml">总佣金： <text class="yjin">{{money}}</text> </text>
					</view>
				</view>
				
			</u-sticky>
			<view class="menlist">
				<!-- <view class="nodata">
					<image class="kzt_img_zwsj" src="@/pages_client/static/mine/img_kzt_sp.png" mode="" />
					<text>暂无商品</text>
				</view> -->
				<view class="oitem" v-for="(item,index) in list" :key="index" @click="getdetail(item)">
					<view class="olist">
						<view class="ohead">
							<text class="ostatus">订单ID:{{item.order_sn}}</text>
							<text class="ostatustwo ml">{{item.status_text}}</text>
						</view>
						<view class="onav" v-for="(i,ind) in item.goods_list" :key="ind">
							<image class="tu" :src="i.goods_image" />
							<view class="navright">
								<view class="navone">
									<text class="bt ellipsis">{{i.goods_name}}</text>			
								</view>
								<view class="navone">
									<view class="yjinl">佣金率： <text class="lv">{{i.bfb}}</text> </view>
								</view>
								
							</view>
						</view>
					</view>
					<view class="fuview">
						<view class="fuitem">
							<text class="fujine">￥<text class="fujinenum">{{item.pay_money||0}}</text></text>
							<text class="fumiao">付款金额</text>
						</view>
						<view class="fuitem">
							<text class="fujine">￥<text class="fujinenum">{{item.jiesuan_money||0}}</text></text>
							<text class="fumiao">结算金额</text>
						</view>
						<view class="fuitem">
							<text class="fujine yong">￥<text class="fujinenum">{{item.server_money||0}}</text></text>
							<text class="fumiao">总佣金</text>
						</view>
					</view>
					<view class="zheitem">
						<view class="items" v-if="item.pay_time">
							<text class="ileft">付款时间:</text>
							<text class="ival">{{item.pay_time||'--'}}</text>
						</view>
						<view class="items" v-if="item.delivery_time">
							<text class="ileft">结算时间::</text>
							<text class="ival{">{{ item.delivery_time||'--' }}</text>
						</view>
					</view>
					<!-- <view class="heview">
						<view class="hename">
							<view class="btn">已加橱窗</view>
							<view class="btn fukuan">加入橱窗</view>
						</view>
					</view> -->
				</view>

				<u-loadmore :status="status" @loadmore="loadmore" />
			</view>
		</view>

		<view class="botview" v-if="isguan">
			<image class="icon_dz_xz_s" src="@/pages_client/static/img/icon_dz_xz_s.png" />
			<text class="quan">全选</text>
			<text class="nums"><text class="numsed">1</text>/3</text>
			<view class="hename" style="margin-left: auto;">
				<view class="btn">删除</view>
				<view class="btn fukuan">置顶</view>
			</view>
		</view>

		<!-- 筛选 -->
		<u-popup  v-model="shaipopshow" mode="bottom" width="100%" ref="auth" :closeable="true" :mask-close-able="true" :custom="true" :mask-click="false" @close="closeshai">
			<view class="shiapop">
				<view class="shaiview">
					<view class="stit">
						商品类目
					</view>
					<view class="shailist">
						<view class="shaiitem sactive">
							美容养颜
						</view>
						<view class="shaiitem">
							美容养颜
						</view>
						<view class="shaiitem">
							美容养颜
						</view>
						<view class="shaiitem">
							美容养颜
						</view>
					</view>
				</view>
				<view class="shaiview">
					<view class="stit">
						商品类目
					</view>
					<view class="shailist">
						<view class="shaiitem sactive">
							美容养颜
						</view>
						<view class="shaiitem">
							美容养颜
						</view>
						<view class="shaiitem">
							美容养颜
						</view>
						<view class="shaiitem">
							美容养颜
						</view>
					</view>
				</view>
				<view class="botzhi">
					<view class="bzhidin">置顶</view>
					<view class="bzhidin que ml">确定</view>
				</view>
			</view>

			
		</u-popup>	

		<u-calendar v-model="timeshow" :mode="mode" @change="timechange"></u-calendar>
	</view>
</template>

<script>
	export default {
		components: {
		},
		data() {
			return {
				value:1,
				name:'',
				isguan:false,
				shaipopshow:false,
				tablist: [{
					name: '待核销'
				}, {
					name: '已核销'
				}, {
					name: '已退款'
				}],
				current: 0,
				value:1,
				shop_id:'',
				type:1,//1电商 2店铺
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",
				orderstatus:'1',//1 已付款 2已收货 3 已结算
				start:'',
				end:'',
				money:0,
				total:0,
				timeshow:false,
				mode: 'date',
				timetype:1,
				title:'电商订单'
			}
		},
		onLoad(option) {
			if(option.shop_id){
				this.shop_id = option.shop_id
			}
			if(option.type){
				this.type = option.type
				if(this.type == 1){
					this.title = '电商订单'
					this.tablist= [{
						name: '待发货'
					}, {
						name: '已发货'
					}, {
						name: '已完成'
					}]
				}else if(this.type == 2){
					this.title = '团购订单'
					this.tablist=[{
						name: '待核销'
					}, {
						name: '已核销'
					}, {
						name: '已退款'
					}]
				}
			}
			this.getList()
		},
		onShow() {
		},
		methods: {//

			closeteam(){
				this.teampopshow = false
			},
			change(index) {
				this.current = index;
				if(this.current == 0){
					this.orderstatus = '1'
				}else if(this.current == 1){
					this.orderstatus = '2'
				}else if(this.current == 2){
					this.orderstatus = '3'
				}
				this.getClear()
			},
			getdetail(item){
				if(this.type == 1){
					this.navrouter('/pages_client/mine/ShopOrderDetail?id='+item.id)
				}
				
			},
			closeshai(){
				this.shaipopshow = false
			},
			async getList(){//列表数据
				if(this.type == 1){
					let res = await this.$u.api.getOrderList({
						limit:this.limit,
						page:this.page,
						shop_id:this.shop_id,
						start:this.start,
						end:this.end,
						status:this.orderstatus
					});
					this.last_page = res.lastpage
					let list = res.list;
					this.money = res.money
					this.total = res.total
					this.list = this.page == 1 ? list : [...this.list, ...list];	
					if(res.list==''||Number(list.length)<Number(this.limit)||Number(this.page)>Number(this.last_page)){
						this.status = 'nomore';
					}
				}else if(this.type == 2){
					let res = await this.$u.api.getOrderListByTuan({
						limit:this.limit,
						page:this.page,
						shop_id:this.shop_id,
						start:this.start,
						end:this.end,
						status:this.orderstatus
					});
					this.last_page = res.lastpage
					let list = res.list;
					this.money = res.money
					this.total = res.total
					this.list = this.page == 1 ? list : [...this.list, ...list];	
					if(res.list==''||Number(list.length)<Number(this.limit)||Number(this.page)>Number(this.last_page)){
						this.status = 'nomore';
					}
				}
				
				
			},
			loadmore() {
				let page = this.page;
				// let last_page = this.last_page;
				if (this.status == 'loadmore') {
					this.page++;
					this.getList();
				}
			},
			getClear(){
				this.list = []
				this.page = 1,
				this.status= "loadmore"
				this.getList()
			},
			timechange(e) {
				console.log(e);
				if(this.timetype == 1){
					this.start = e.result
				}else if(this.timetype == 2){
					this.end = e.result
				}
				this.getClear()
			},
			gettime(e){
				this.timetype = e
				this.timeshow = true
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #f9f9f9;
	}
	.content{
		background-color: #f9f9f9;
		padding-bottom: 30rpx;
		.xuanview{
			display: flex;
			flex-direction: column;
			background-color: #fff;
			padding: 15rpx 30rpx 0rpx;

		}
		.souviewtwo{
			display: flex;
			background: #F8F8F8;
			border-radius: 6rpx;
			padding:20rpx;
			width: 100%;
			align-items: center;
			.dinname{
				font-weight: 500;
				font-size: 26rpx;
				color: #333333;
			}
			.riitem{
				flex: 1;
				display: flex;
				flex-direction: row;
				font-weight: bold;
				font-size: 28rpx;
				color: #1A1A1A;
				justify-content: center;
			}
			.hxian{
				display: inline-block;
				margin: 0 8rpx;
				font-weight: bold;
				font-size: 28rpx;
				color: #1A1A1A;
			}
		}
		.zong{
			display: flex;
			flex-direction: row;
			align-items: center;
			padding: 15rpx;
			margin-top: 10rpx;
			border-top: 1rpx  solid #eee;
			.zongnum{
				font-weight: 500;
				font-size: 24rpx;
				color: #808080;
			}
			.yjin{
				font-weight: 500;
				font-size: 24rpx;
				color: #1A1A1A;
			}
		}
		.tuanone{
			
			display: flex;
			flex-direction: row;
			align-items: center;
			width: 100%;
			margin-top: 0rpx;
			
			.pai{
				flex: 1;
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: center;
				.painame{
					font-weight: bold;
					font-size: 26rpx;
					color: #333333;
				}
				.paiimg{
					width: 40rpx;
					height: 40rpx;
					margin-left: 4rpx;
				}
				.guanname{
					color: #F90101;
				}
			}
			.tuhead{
				max-width: 80%;
				white-space: nowrap;
				.tuitem{
					padding: 8rpx 20rpx;
					background: #F5F5F5;
					border-radius: 10rpx;
					margin-right: 20rpx;
					font-weight: 500;
					font-size: 26rpx;
					color: #333333;
					display: inline-block;
				}
				.tactive{
					background: #52443B;
					color: #fff;
				}
			}
			.icon_tx{
				margin-left: auto;
				width: 40rpx;
				height: 40rpx;
			}
		}	
	}
	.nlist{
		padding: 20rpx;
		display: flex;
		flex-direction: column;
		.nitem{
			padding: 20rpx 25rpx;
			background: #FFFFFF;
			border-radius: 30rpx;
			.nione{
				display: flex;
				flex-direction: row;
				align-items: center;
				.tous{
					width: 81rpx;
					border-radius: 50%;
					height: 81rpx;
					margin-right: 15rpx;
				}
				
				.niright{
					width: 82%;
					display: flex;
					flex-direction: column;
					.rione{
						display: flex;
						flex-direction: row;
						align-items: center;
						.riname{
							max-width: 80%;
							display: inline-block;
							font-weight: bold;
							font-size: 32rpx;
							color: #333333;
						}
						.hyuan{
							width: 80rpx;
							height: 32rpx;
							background: linear-gradient(-90deg, #272727, #4D4D4D);
							border-radius: 6rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							font-weight: 500;
							font-size: 22rpx;
							color: #FFFFFF;
							margin-left: 10rpx;
						}
						.idname{
							font-weight: 400;
							font-size: 24rpx;
							color: #999999;
						}
						.hui{
							margin-left: 40rpx;
						}

					}
					.mttwo{
						margin-top: 15rpx;
					}
				}
				.comm_icon_next{
					margin-left: auto;
					width: 24rpx;
					height: 24rpx;
				}
			}
			.zheview{
				border-top: 1rpx solid #eee;
				display: flex;
				flex-direction: column;
				margin-top: 20rpx;
				padding-top: 20rpx;
				.zheitem{
					display: flex;
					flex-direction: row;
					flex-wrap: wrap;
					.items{
						width: 50%;
						display: flex;
						flex-direction: row;
						align-items: center;
						margin-bottom: 10rpx;
						.ileft{
							font-weight: 500;
							font-size: 24rpx;
							color: #999999;
						}
						.ival{
							font-weight: 500;
							font-size: 26rpx;
							color: #333333;
						}
					}
				}
				.shengbtn{
					display: flex;
					flex-direction: row;
					justify-content: flex-end;
					padding: 0 20rpx 20rpx 0;
					.sbtn{
						padding: 15rpx 25rpx;
						background: #52443B;
						border-radius: 16rpx 16rpx 16rpx 16rpx;
						font-weight: bold;
						font-size: 28rpx;
						color: #FFFFFF;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
	.botview{
		position: fixed;
		height: 120rpx;
		width: 100%;
		bottom: 0;
		background-color: #fff;
		z-index: 10;
		padding: 0 30rpx;
		display: flex;
		align-items: center;
		.icon_dz_xz_s{
			width: 40rpx;
			margin-right: 10rpx;
			height: 40rpx;
		}
		.quan{
			font-weight: 500;
			font-size: 28rpx;
			color: #666666;
		}
		.nums{
			font-weight: 500;
			font-size: 28rpx;
			color: #808080;
			display: inline-block;
			margin-left: 100rpx;
			.numsed{
				font-weight: 500;
				font-size: 28rpx;
				color: #FF7C41;
			}
		}

		.tjia{
			width: 100%;
			height: 90rpx;
			background: #52443B;
			border-radius: 16rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: bold;
			font-size: 28rpx;
			color: #FFFFFF;
		}
	}
	.menlist{
		padding:30rpx 22rpx;
	}
	.oitem{
		display: flex;
		flex-direction: column;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin-bottom: 24rpx;
		padding: 30rpx;
		.ohead{
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 30rpx;
			.icon_sj{
				width: 30rpx;
				height: 30rpx;
				margin-right: 9rpx;
			}
			.dianname{
				max-width: 70%;
				display: inline-block;
				font-weight: bold;
				font-size: 28rpx;
				color: #272727;
			}
			.zt{
				font-weight: 500;
				font-size: 25rpx;
				color: #FF0050;
			}
		}
		.olist{
			display: flex;
			flex-direction: column;
			.ohead{
				display: flex;
				flex-direction: row;
				border-bottom: 1rpx solid #eee;
				padding-bottom: 15rpx;
				.ostatus{
					font-weight: 500;
					font-size: 26rpx;
					color: #333333;
				}
				.ostatustwo{
					font-weight: 500;
					font-size: 26rpx;
					color: #BBBBBB;
				}
			}
			.icon_dz_xz_s{
				width: 40rpx;
				margin-right: 20rpx;
				height: 40rpx;
			}
			.onav{
				display: flex;
				flex-direction: row;
				margin-bottom: 20rpx;
				// align-items: center;
				
				.tu{
					width:180rpx;
					height: 180rpx;
					border-radius: 10rpx;
					margin-right: 14rpx;
				}
				.navright{
					width: 68%;
					display: flex;
					flex-direction: column;
					padding: 15rpx 0;

					.navone{
						display: flex;
						flex-direction: row;
						margin-bottom: auto;
						.yjinl{
							font-weight: 400;
							font-size: 20rpx;
							color: #808080;
						}
						.lv{
							font-weight: bold;
							font-size: 20rpx;
							color: #1A1A1A;
						}
						.tuan{
							padding: 2rpx 8rpx;
							background: #FF7C41;
							border-radius: 6rpx;
							font-weight: 500;
							font-size: 20rpx;
							color: #FFFFFF;
							margin-right: 10rpx;
						}
						.bt{
							max-width: 100%;
							display: inline-block;
							font-weight: 500;
							font-size: 28rpx;
							color: #222222;
							height: 80rpx;
						}
						.ellipsis {
						display: -webkit-box;
						-webkit-line-clamp: 2; /* 限制行数为2 */
						-webkit-box-orient: vertical;
						overflow: hidden;
						}

						.btmiao{
							max-width: 80%;
							display: inline-block;
							font-weight: 500;
							font-size: 20rpx;
							color: #BBBBBB;
						}
						.jia{
							font-weight: bold;
							font-size: 26rpx;
							color: #1A1A1A;
						}
						.zheng{
							padding: 4rpx 20rpx;
							border-radius: 6rpx;
							border: 1px solid #999999;
							font-weight: 500;
							font-size: 20rpx;
							color: #999999;
						}
					}
					.navone:last-child{
						margin-bottom: 0;
					}
					.shoujia{
						font-weight: 400;
						font-size: 25rpx;
						display: block;
						margin-top: 8rpx;
						color: #1A1A1A;
					}
					.yugu{
						// background: #F9F9F9;
						border-radius: 6rpx;
						display: flex;
						flex-direction: row;
						// padding: 8rpx 20rpx;
						margin: 5rpx 0;
						
						.yuguleft{
							flex: 1;
							display: flex;
							flex-direction: column;
							justify-content: center;
							align-items: center;
							// border-right: 1rpx solid #eee;
							.yuname{
								font-weight: 500;
								font-size: 20rpx;
								color: #BBBBBB;
							}
							
							.jia{
								font-weight: bold;
								font-size: 30rpx;
								color: #1A1A1A;
								margin-top: 10rpx;
								display: block;
								.jiabai{
									font-weight: 500;
									font-size: 20rpx;
									color: #808080;
									display: inline-block;
									margin-left: 9rpx;
									position: relative;
									top: -2rpx;
								}
								
							}
							.huo{
								color: #F97001;
							}
							.zhuan{
								font-weight: 500;
								font-size: 20rpx;
								color: #F97001;
							}
						}
						.yuguleft:last-child{
							border-right: none;
						}
					}
				}
			}
			.onav:last-child{
				margin-bottom: 0;
			}
			
			.baoyou{
				padding: 3rpx 10rpx;
				border-radius: 2rpx;
				font-weight: 500;
				font-size: 18rpx;
				color: #F97001;
				border: 1px solid #F97001;
			}
		}
		.fuview{
			background: #F9F9F9;
			border-radius: 12rpx;
			padding: 30rpx 0;
			display: flex;
			flex-direction: row;
			.fuitem{
				border-right: 1rpx solid #eee;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				flex: 1;
				.fujine{
					font-weight: bold;
					font-size: 20rpx;
					color: #1A1A1A;
				}
				.fujinenum{
					font-size: 28rpx;
				}
				.fumiao{
					font-weight: 400;
					font-size: 22rpx;
					color: #BBBBBB;
					display: block;
					margin-top: 8rpx;
				}
				.yong{
					color: #FF7C41;
				}
			}
			.fuitem:last-child{
				border-right: none;
			}
		}
		.heview{
			display: flex;
			flex-direction: column;
			margin-top: 20rpx;
			
		}
	}
	.hename{
		font-weight: 500;
		font-size: 24rpx;
		color: #666666;
		margin: 13rpx 0;
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
	}
	.btn{
		padding: 12rpx 25rpx;
		background: #F3F3F3;
		border-radius: 10rpx;
		font-weight: 500;
		font-size: 26rpx;
		color: #808080;
		margin-left: 20rpx;
		min-width: 160rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.fukuan{
		background: #52443B;
		color: #fff;
		border: none;
	}
	.queren{
		background: #483C38;
		color: #fff;
		border: none;
	}
	.nodata{
		margin: 200rpx auto;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		.kzt_img_zwsj{
			width: 237rpx;
			height: 256rpx;

		}
		text{
			font-weight: 400;
			font-size: 28rpx;
			color: #808080;
			display: block;
			margin-top: 30rpx;
		}
	}
	.shengku{
		font-weight: 500;
		font-size: 28rpx;
		color: #999999;
		display: block;
		margin-top: 8rpx;
	}
	.tablei{
		padding: 10rpx 90rpx 8rpx;
		display: flex;
		flex-direction: row;
		
		.leiitem{
			height: 68rpx;
			background: #F3F3F3;
			border-radius: 34rpx;
			display: flex;
			flex-direction: row;
			width: 100%;
			.tabitem{
				width: 50%;
				height: 100%;
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
				font-weight: bold;
				font-size: 32rpx;
				color: #666666;
			}
			.tactive{
				background: #52443B;
				border-radius: 34rpx;
				color: #fff;
			}
		}
	}
	.menitem{
                display: flex;
                flex-direction: row;
                align-items: center;
                background: #FFFFFF;
                border-radius: 24rpx;
                padding: 25rpx;
                margin: 0 30rpx 20rpx;
                .tu{
                    width: 180rpx;
                    height: 180rpx;
                    margin-right: 20rpx;
                    border-radius: 20rpx;
                }
                .menone{
                    display: flex;
                    flex-direction: column;
                    width: 68%;
                    // height: 100%;
                    .menhead{
                        display: flex;
                        flex-direction: row;
                        align-items: center;
                        .name{
                            font-weight: bold;
                            font-size: 32rpx;
                            color: #272727;
                        }
                        .yingye{
                            font-weight: 500;
                            font-size: 26rpx;
                            color: #24B924;
                        }
                        .yingtime{
                            font-weight: 500;
                            font-size: 26rpx;
                            color: #333333;
                            display: inline-block;
                            margin-left: 18rpx;
                        }
                        .icon_dw{
                            width:22rpx;
                            height: 24rpx;
                            margin-right: 8rpx;

                        }
                        .ju{
                            font-weight: 500;
                            font-size: 28rpx;
                            color: #1A1A1A;
                        }
                        .juli{
                            margin-left: 30rpx;
                            font-weight: 500;
                            font-size: 24rpx;
                            color: #999999;
                            display: inline-block;
                            max-width: 70%;
                        }
						.tiview{
							margin-left: auto;
							width: 200rpx;
							height: 68rpx;
							background: #52443B;
							border-radius: 16rpx 16rpx 16rpx 16rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							font-weight: bold;
							font-size: 28rpx;
							color: #FFFFFF;
						}
                    }
                    .mennav{
                        margin-top: 35rpx;
                    }
                }
            }
        // }

		// 筛选弹窗
		.shiapop{
			padding: 30rpx;
			border-radius: 30rpx 30rpx 0 0 ;
			background-color: #fff;
			.stit{
				font-weight: bold;
				font-size: 30rpx;
				color: #333333;
				display: block;
				margin-bottom: 30rpx;
			}
			.shailist{
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				.shaiitem{
					padding: 16rpx 20rpx;
					background: #F5F5F5;
					border-radius: 10rpx;
					font-weight: 500;
					font-size: 26rpx;
					color: #333333;
					margin: 0 20rpx 20rpx 0;
				}
				.sactive{
					border: 1px solid #FF7C41;
					background: #FFF2ED;
					color: #FF7C41;
				}
			}
			.shaiview{
				margin-bottom: 40rpx;
			}
			.shaiview:last-child{
				margin-bottom: 0;
			}
			.botzhi{
				display: flex;
				margin-top: 50rpx;
				flex-direction: row;
				align-items: center;
				.bzhidin{
					width: 48%;
					height: 91rpx;
					border-radius: 16rpx;
					border: 1px solid #52443B;
					font-weight: 500;
					font-size: 28rpx;
					color: #52443B;
					display: flex;
					align-items: center;
					justify-content: center;

				}
				.que{
					background: #52443B;
					color: #fff;
				}
			}
		}

		.zheitem{
				display: flex;
				flex-direction: column;
				flex-wrap: wrap;
				margin-top: 20rpx;
				.items{
					width: 100%;
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-bottom: 10rpx;
					.ileft{
						font-weight: 500;
						font-size: 24rpx;
						color: #999999;
					}
					.ival{
						font-weight: 500;
						font-size: 26rpx;
						color: #333333;
					}
				}
			}
			/deep/.u-drawer-bottom{
				background-color: #fff !important;
			}
</style>
